package com.wang.controller.outer;

import com.wang.domain.Goods;
import com.wang.dto.GoodsDTO;
import com.wang.service.IGoodsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangyandong
 * @date 2020/1/31 22:28
 */
@RestController
@RequestMapping("/outer/goods/")
public class GoodsOuterController {

    @Autowired
    private IGoodsService goodsService;

    @GetMapping("/getById/{goodsId}")
    public GoodsDTO getById(@PathVariable("goodsId") Integer goodsId){
        Goods goodsOrder = goodsService.getById(goodsId);
        GoodsDTO goodsDTO = new GoodsDTO();
        BeanUtils.copyProperties(goodsOrder,goodsDTO);
        return goodsDTO;
    }
}
